//
//  OrderNormalCell.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/7/31.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit
import SVProgressHUD

class OrderNormalCell: BaseTableViewCell {
    
    @IBOutlet weak var leftImageView: UIImageView!
    
    @IBOutlet weak var desLabel: UILabel!
    
    @IBOutlet weak var priceLabel: UILabel!
    
    @IBOutlet weak var countLabel: UILabel!
    
    @IBOutlet weak var priLabelConstrW: NSLayoutConstraint!
    
    @IBOutlet weak var indicatorView: UIActivityIndicatorView!
    
    lazy var tempLabel : UILabel = {
    
    let temp = UILabel()
    
        temp.font = UIFont.systemFont(ofSize: 15)
    
        return temp
    }()
    
    var model : OrderGoodsModel?{
    
        didSet{
        
            if model != nil {
                
                indicatorView.startAnimating()
                leftImageView.sd_setImage(with: URL(string :model!.goods_image_url), placeholderImage: UIImage.defaulImage(), options: []) { (image, _, _, _) in
                    self.indicatorView.stopAnimating()
                    
                }
                
                desLabel.text = model?.goods_name 
                
                priceLabel.text = "¥ " + model!.goods_price
                
                if priceLabel.text != nil {
                    tempLabel.text = priceLabel.text
                    
                    tempLabel.sizeToFit()
                    
                    
                    priLabelConstrW.constant = tempLabel.frame.size.width
                    
                }else{
                
                
                    priLabelConstrW.constant = 60

                }
                
                
                
                countLabel.text = "X" + model!.goods_num
  
                
            }
        
        
        }
    
    
    }


    override func awakeFromNib() {
        super.awakeFromNib()
        
        countLabel.textColor = UIColor.dakGray()
        
        contentView.backgroundColor = UIColor.white

        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
